package com.crm.system.controller.orderManager;

import com.alibaba.fastjson.JSONObject;
import com.crm.common.model.DataResponse;
import com.crm.common.model.DhResponse;
import com.crm.common.model.Enum.ResponseCodeEnum;
import com.crm.model.entity.orderManager.CustomerOrderInvoice;
import com.crm.model.vo.orderManager.PerformanceRankVO;
import com.crm.system.service.orderManager.CustomerProductOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;

/**
 * 个人业绩报表-订单业绩
 * @author luojie
 * @date 2021/4/27 14:17
 */
@RestController
@RequestMapping("/orderInvoice")
@Slf4j
public class CustomerOrderPersonalStatisticsController {

    @Autowired
    private CustomerProductOrderService customerProductOrderService;

    /***
     * @Description:会员非会员总额度统计
     * @Param:yearMark 查询月份(传12是今年，传24是去年)
     * @Author: luojie
     * @Date: 2021/4/27 22:26
     */
    @GetMapping("/selectAnnualAmount")
    private DataResponse selectAnnualAmount(@RequestParam Integer yearMark,@RequestParam String accountId){
        JSONObject result = customerProductOrderService.selectAnnualAmount(yearMark,accountId);
        return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),result);
    }

    /***
     * @Description:查询本月业绩饼图
     * @param accountId 账号id
     * @Author: luojie
     * @Date: 2021/4/27 22:46
     */
    @GetMapping("/selectThisMonthPerformance")
    private DataResponse selectThisMonthPerformance(@RequestParam String accountId){
        JSONObject result = customerProductOrderService.selectThisMonthPerformance(accountId);
        return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),result);
    }

    /***
     * @Description:查询业绩排名(除了超级管理员其余都是查本公司全部业绩)
     * @Author: luojie
     * @Date: 2021/4/29 9:23
     */
    @GetMapping("/selectPerformanceRank")
    public DataResponse selectPerformanceRank(HttpServletRequest request){
        List<PerformanceRankVO> orderActivityRelationProductNames = customerProductOrderService.selectPerformanceRank();
        return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),orderActivityRelationProductNames);
    }

    /***
     * @Description:根据个人id和时间范围统计合同信息
     * @Param: accountId 用户id
     * @Param: dateType 时间标识
     * @Author: luojie
     * @Date: 2021/4/29 13:53
     */
    @GetMapping("/selectStatisticsContractInformation")
    public DataResponse selectStatisticsContractInformation(HttpServletRequest request,
                                                            @RequestParam String dateType,
                                                            @RequestParam String accountId){
        JSONObject result = customerProductOrderService.selectStatisticsContractInformation(dateType,accountId);
        return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),result);
    }
}
